package com.haoliang.spring.component.lifecycle.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Author zhaohaoliang
 * @Date 创建于 下午6:19 2019/3/10
 * @Description 请输入类的描述信息
 */
@Component
public class CustomBeanPostProcessor implements BeanPostProcessor {
    /**
     * 初始化之前工作
     *
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization" + beanName + ":" + bean);
        return bean;
    }

    /**
     * 初始化之后工作
     *
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization" + beanName + ":" + bean);
        return bean;
    }
}
